<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchList">
        <a-row :gutter="48">
          <a-col :xxl="6" :xl="6" :lg="12" :sm="24">
            <a-form-item label="订单号">
              <a-input v-model="queryParam.orderSn" placeholder="请输入订单号" />
            </a-form-item>
          </a-col>
          <a-col :md="18" :sm="24">
            <span class="table-page-search-submitButtons" :style="{ float: 'right', overflow: 'hidden' }">
              <a-button type="primary" @click="searchList">查询</a-button>
              <a-button style="margin-left: 18px" @click="resetList">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <s-table ref="table" size="default" :rowKey="record => record.id" :columns="columns" :data="loadData" :pagination="paginationProps"> </s-table>
  </a-card>
</template>
    
<script>
import { STable } from '@/views/box/components'
import { orderState } from '@/api/box/marketing'
const columns = [
  { title: '订单号', dataIndex: 'orderSn', align: 'center', width: '220px' },
  { title: '异常原因', dataIndex: 'errMsg', align: 'center' }
]
export default {
  components: {
    STable
  },
  data() {
    return {
      columns,
      queryParam: {
        orderSn: ''
      },
      paginationProps: {
        total: 0,
        showTotal: total => `共有 ${total} 条数据`
      },
      loadData: parameter => {
        const queryParam = this.queryParam
        const data = {}
        data.page = parameter
        data.requestData = queryParam

        return orderState(data).then(res => {
          if (res.code === 0) {
            const data = {
              data: res.data,
              page: res.page
            }
            console.log(data)
            return data
          } else {
            this.$message.error(res.msg)
            const data = {
              page: {
                pageNo: 0,
                count: 0,
                pageSize: 10
              },
              data: []
            }
            return data
          }
        })
      }
    }
  },
  methods: {
    searchList() {
      this.$refs.table.refresh(true)
    },
    resetList() {
      this.queryParam.orderSn = ''
      this.$refs.table.refresh(true)
    }
  }
}
</script>
    
<style>
</style>